package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.inspect.BpInspectRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.LocalDateTime;
import java.util.List;

public interface BpInspectRecordRepository extends JpaRepository<BpInspectRecord, Long>, JpaSpecificationExecutor<BpInspectRecord> {

    List<BpInspectRecord> findByInspectPlanId(Long inspectPlanId);

    @Query("select br from BpInspectRecord br where br.id=:id")
    BpInspectRecord findOneById(Long id);

    List<BpInspectRecord> findByInspectUserIdAndAppPlanTaskId(@Param("inspectUserId") Long inspectUserId, @Param("appPlanTaskId") Long appPlanTaskId);

    List<BpInspectRecord> findByAppPlanTaskId(Long appPlanTaskId);

    List<BpInspectRecord> findByCreateTimeBetween(LocalDateTime startTime, LocalDateTime endTime);

    List<BpInspectRecord> findByAppPlanTaskIdIn(List<Long> appPlanTaskIds);

}
